package com.jiexin.controller;

import com.jiexin.common.JsonData;
import com.jiexin.param.RoleParam;
import com.jiexin.param.WorkFlowParam;
import com.jiexin.service.PlmWorkFlowService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * @Author: Jay_Liu
 * @Description:
 * @Date: Created in 15:13 2018/5/18 0018
 * @Modified By:
 */
@Controller
@RequestMapping("/plm/workFlow")
public class PlmWorkFlowController {

    @Resource
    private PlmWorkFlowService plmWorkFlowService;

    @RequestMapping("/approver.page")
    public ModelAndView page(){
        return new ModelAndView("approver");
    }

    @RequestMapping("/save.json")
    @ResponseBody
    //保存
    public JsonData saveWorkFlow(WorkFlowParam workFlowParam) {
        plmWorkFlowService.save(workFlowParam);
        return JsonData.success();
    }

    @RequestMapping("/update.json")
    @ResponseBody
    //更新
    public JsonData updateWorkFlow(WorkFlowParam workFlowParam) {
        plmWorkFlowService.update(workFlowParam);
        return JsonData.success();
    }

    @RequestMapping("/delete.json")
    @ResponseBody
    //删除
    public JsonData deleteWorkFlow(int workFlowId) {
        plmWorkFlowService.delete(workFlowId);
        return JsonData.success();
    }

    @RequestMapping("/list.json")
    @ResponseBody
    //系统工作流数据
    public JsonData list() {
        return JsonData.success(plmWorkFlowService.getAllWorkFlow());
    }
}
